//
//  NTDataPlayer.m
//  NT
//
//  Created by blank zhang on 12-5-12.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "DTPlayer.h"
#import "NTDataWriter.h"
#import "NTDataReader.h"

@implementation DTPlayer
-(void)serialize:(NTDataWriter*)writer {
    [writer writeString:name];
//    [writer writeInt:score];
    [writer writeInt:profession];
    [writer writeInt:sex];
    [writer writeInt:level];
    [writer writeInt:hpMax];
    [writer writeInt:mpMax];
    [writer writeInt:attack];
    [writer writeInt:speed];
    [writer writeInt:defense];
    [writer writeInt:defenseBreak];
    [writer writeInt:dodge];
    [writer writeInt:hit];
    [writer writeInt:critical];
    [writer writeInt:criticalBreak];
    [writer writeInt:country];    
    [writer writeIntArray:skills Size:skillCount];
    [writer writeIntArray:equipments Size:equipmentCount];
}

-(void)unserialize:(NTDataReader*)reader {
    name = (char*)[reader readString];
    profession = [reader readInt];
    sex = [reader readInt];
    level = [reader readInt];
    hpMax = [reader readInt];
    mpMax = [reader readInt];
    attack = [reader readInt];
    speed = [reader readInt];
    defense = [reader readInt];
    defenseBreak = [reader readInt];
    dodge = [reader readInt];
    hit = [reader readInt];
    critical = [reader readInt];
    criticalBreak = [reader readInt];
    country = [reader readInt];
    skills = (int*)[reader readIntArray:&skillCount];
    equipments = (int*)[reader readIntArray:&equipmentCount];
    score = [reader readInt];
}
@end

